package config

import (
	"errors"
	"github.com/spf13/viper"
)

func Load(file string, outConf interface{}) (err error) {
	if len(file) == 0 {
		return errors.New("invalid config file")
	}

	theViper := viper.New()
	theViper.SetConfigFile(file)
	err = theViper.ReadInConfig()
	if err != nil {
		return err
	}
	err = theViper.Unmarshal(outConf)
	if err != nil {
		return err
	}
	return nil
}
